﻿package frEngine.shader.filters.vertexFilters
{
    import __AS3__.vec.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.vertexFilters.def.*;

    public class Line3dFilter extends VertexFilter
    {
        private var lineParams:Vector.<Number>;

        public function Line3dFilter()
        {
            this.lineParams = this.Vector.<Number>([0.001, 1, -1, -1]);
            super(FilterType.Transform);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{lineParams}", true).value = this.lineParams;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "Line3d0";
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:Array = [];
            _loc_3.push(new ToBuilderInfo("vm1", FilterName.worldView, true, 4));
            _loc_3.push(new ToBuilderInfo("vc5", "{lineParams}", false, 1, this.lineParams));
            _loc_3.push(new ToBuilderInfo("va0", FilterName.POSITION, false, 3));
            _loc_3.push(new ToBuilderInfo("va1", FilterName.PARAM0, false, 3));
            _loc_3.push(new ToBuilderInfo("va2", FilterName.PARAM1, false, 1));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + "m44           vt0           va0           vm1\t\t\n";
            _loc_4 = _loc_4 + "m44           vt1           va1           vm1\t\t\n";
            _loc_4 = _loc_4 + "sub           vt2           vt1           vt0\t\t\n";
            _loc_4 = _loc_4 + "slt           vt3           vt0.z         vc5.y\t\t\n";
            _loc_4 = _loc_4 + "sub           vt3.y         {vcConst1}.z  vt3.x\t\t\n";
            _loc_4 = _loc_4 + "sub           vt3.z         vt0.xxz       vc5.y\t\t\n";
            _loc_4 = _loc_4 + "sub           vt3.w         vt0.xxxz      vt1.xxxz\t\n";
            _loc_4 = _loc_4 + "div           vt4           vt3.z         vt3.w\t\t\n";
            _loc_4 = _loc_4 + "mul           vt5           vt2           vt4.x\t\t\n";
            _loc_4 = _loc_4 + "add           vt4           vt0           vt5\t\t\n";
            _loc_4 = _loc_4 + "mul           vt5           vt3.x         vt4\t\t\n";
            _loc_4 = _loc_4 + "mul           vt4           vt0           vt3.y\t\t\n";
            _loc_4 = _loc_4 + "add           vt0           vt5           vt4\t\t\n";
            _loc_4 = _loc_4 + "crs           vt3.xyz       vt2           vt1\t\t\n";
            _loc_4 = _loc_4 + "nrm           vt1.xyz       vt3\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt2.xyz       vt1           va2.x\t\t\n";
            _loc_4 = _loc_4 + "mul           vt1.x         vt0.z         vc5.x\t\t\n";
            _loc_4 = _loc_4 + "mul           vt3.xyz       vt2           vt1.x\t\t\n";
            _loc_4 = _loc_4 + "add           {output}  \tvt0           vt3\t\t\n";
            _loc_4 = _loc_4 + "mov           {output}.w         {vcConst1}.z\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            param1.OpType = ECalculateOpType.Proj;
            return _loc_4;
        }// end function

    }
}
